var vm = new Vue({
    el: '#app',
    data: {
        host: host,
        username: '',
        password: '',
        password2: '',
        mobile: '',
    },
    mounted: function(){
    },
    methods: {
        // 注册
        on_submit_register: function(){
                axios.post(this.host + '/users/', {
                        username: this.username,
                        password: this.password,
                        password2: this.password2,
                        mobile: this.mobile,
                    }, {
                        responseType: 'json'
                    })
                    .then(response => {
                        // 记录用户的登录状态
                        sessionStorage.clear();
                        localStorage.clear();
                        localStorage.username = response.data.username;
                        localStorage.user_id = response.data.id;
                        location.href = '/index.html';
                    })
                    .catch(error=> {
                        sessionStorage.clear();
                        localStorage.clear();
                        alert(error.response.data)
                    })

        }
    }
});